subroutine init2d(a,i,i_vertex2D,i_nVer2D,i_nInCat2D,i_igT,i_jgT,i_ggT,i_ig,i_jg,i_ggl,i_ggu,i_di,i_f,&
    i_v1,i_v2,i_v3,i_v4,i_v5,i_ggl2,i_ggu2,i_di2,i_Hfi,i_points,i_l1,i_numbersEl,i_params)
    dimension a(100000000),i(100000000)
    real*8 a,eps2d,eps3d,radiusRED
    integer rz_dat,tsize_dat,gg_dat,elemsCount2D,typeTask,typeTask_txt,points_txt,sigma_txt
    common /files_task2d/inf2tr_dat,nvkat2d_dat,rz_dat,nvtr_dat,tsize_dat,ig_dat,jg_dat,gg_dat,points_txt,&
    l1_dat,sigma_txt
    common /commonInfo/ eps2d,eps3d,radiusRED,maxiter,typeTask,nt,nMaterials
    common /commonIndex/ indexI,indexA
    common /characteristics/ nPoints
    common /dimTask2D/nodesCount2D,elemsCount2D,nodesBoundCount2D,nodesTermCount2D,m2D,mTerm2d,&
    nodesNotTermCount2D,nMaterials2d
    common /files_common/infite_0,num_slae,log_txt,typeTask_txt

    call open_files_init2d()

    !input 2D data
101 format(' ISLAU=',i8,' INDKU1=',i8,' INDFPO=',i8)
102 format('KUZLOV=',i8,'    KPAR=',i8,'    KT1=',i8,'    KT2=',i8,'    KT3=',i8)
103 format('KISRS1=',i8,' KISRS2=',i8,' KISRS3=',i8,'   KBRS=',i8)
104 format('KREB4 =',i8,' KTSIM =',i8)
    read(inf2tr_dat,101)k,k,k
    read(inf2tr_dat,102) nodesCount2D,elemsCount2D,nodesBoundCount2D,k1,k2
    read(inf2tr_dat,103) k,k,k,k
    read(inf2tr_dat,104) kreb4,k
    read(tsize_dat,*)nodesTermCount2D
    nodesNotTermCount2D = nodesCount2D-nodesTermCount2D
    read(points_txt,*)nPoints

    i_params   = indexA
    call inputParams_task2d(a(i_params),sigma_txt,nMaterials2d)
    i_vertex2D = i_params+nMaterials2d
    i_points   = i_vertex2D + 2*nodesCount2D
    i_ggT      = i_points+3*nPoints
    i_nVer2D   = indexI
    i_nInCat2D = i_nVer2D+6*elemsCount2D
    i_l1       = i_nInCat2D+elemsCount2D
    i_numbersEl= i_l1+nodesBoundCount2D
    i_igT      = i_numbersEl+4*nodesCount2D
    i_jgT      = i_igT+nodesTermCount2D+1
    call inputForTask2d(a(i_vertex2D),i(i_nVer2D),i(i_nInCat2D),i(i_igT),i(i_jgT),a(i_ggT),a(i_points),i(i_l1),&
    i(i_numbersEl))
    i_listbeg = i_jgT+mTerm2d
    i_ig      = i_listbeg+nodesNotTermCount2D
    i_jg      = i_ig+nodesNotTermCount2D+1
    call portrait(i(i_ig),i(i_jg),nodesCount2D,elemsCount2D,i(i_nVer2D),m2d,i(i_listbeg),6,4,i(i_igT),i(i_jgT),&
    mTerm2d,nodesNotTermCount2D)
    i_ggl  = i_ggT+mTerm2d
    i_ggu  = i_ggl+m2d
    i_di   = i_ggu+m2d
    i_f    = i_di+nodesNotTermCount2D
    i_v1   = i_f+nodesNotTermCount2D
    i_v2   = i_v1+nodesNotTermCount2D
    i_v3   = i_v2+nodesNotTermCount2D
    i_v4   = i_v3+nodesNotTermCount2D
    i_v5   = i_v4+nodesNotTermCount2D
    i_ggl2 = i_v5+nodesNotTermCount2D
    i_ggu2 = i_ggl2+m2d
    i_di2  = i_ggu2+m2d
    i_Hfi  = i_di2+nodesNotTermCount2D

1   format(A,i8,' nElement =',i8)
    write(*,1)'task2d:            nVertex =',nodesCount2D,elemsCount2D
    write(log_txt,1)'task2d:            nVertex =',nodesCount2D,elemsCount2D
end
!*************************************************************************
subroutine open_files_init2d()
    common /files_task2d/inf2tr_dat,nvkat2d_dat,rz_dat,nvtr_dat,tsize_dat,ig_dat,jg_dat,gg_dat,&
    points_txt,l1_dat,sigma_txt
    integer rz_dat,tsize_dat,gg_dat,points_txt,sigma_txt
    inf2tr_dat = 101
    nvkat2d_dat = 102
    rz_dat = 103
    nvtr_dat = 104
    tsize_dat = 105
    ig_dat = 106
    jg_dat = 107
    gg_dat = 108
    l1_dat = 109
    sigma_txt = 110
    open(inf2tr_dat,file='.\calculations\mesh2dHfi\inf2tr.dat',mode='read')
    open(nvkat2d_dat,file='.\calculations\mesh2dHfi\nvkat2d.dat',access='direct',recl=4,mode='read')
    open(rz_dat,file='.\calculations\mesh2dHfi\rz.dat',access='direct',recl=16,mode='read')
    open(nvtr_dat,file='.\calculations\mesh2dHfi\nvtr.dat',access='direct',recl=24,mode='read')
    open(tsize_dat,file='.\calculations\mesh2dHfi\tsize.dat',mode='read')
    open(ig_dat,file='.\calculations\mesh2dHfi\ig.dat',access='direct',recl=4,mode='read')
    open(jg_dat,file='.\calculations\mesh2dHfi\jg.dat',access='direct',recl=4,mode='read')
    open(gg_dat,file='.\calculations\mesh2dHfi\gg.dat',access='direct',recl=8,mode='read')
    open(l1_dat,file='.\calculations\mesh2dHfi\l1.dat',access='direct',recl=4,mode='read')
    open(sigma_txt,file='.\calculations\mesh2dHfi\sigma',mode='read')

    points_txt=201
    open(points_txt,file='.\calculations\points.txt',mode='read')
end
!*************************************************************************
subroutine inputForTask2d(vertex,nVer,nInCat2D,igT,jgT,ggT,points,l1,numbersEl)
    common /files_task2d/inf2tr_dat,nvkat2d_dat,rz_dat,nvtr_dat,tsize_dat,&
    ig_dat,jg_dat,gg_dat,points_txt,l1_dat,sigma_txt
    common /dimTask2D/nodesCount2D,elemsCount2D,nodesBoundCount2D,nodesTermCount2D,&
    m2D,mTerm2d,nodesNotTermCount2D,nMaterials2d
    common /boundaryTask2D/maxR,maxZ,minR,minZ
    common /characteristics/ nPoints
    integer rz_dat,tsize_dat,gg_dat,points_txt,sigma_txt
    integer elemsCount2D
    real*8 vertex,ggT,points,maxR,maxZ,minR,minZ
    dimension vertex(2,nodesCount2D),nVer(6,elemsCount2D),nInCat2D(elemsCount2D),&
    igT(nodesTermCount2D+1),jgT(*),ggT(*),points(3,nPoints),l1(nodesBoundCount2D),&
    numbersEl(4,nodesCount2D)

    read(rz_dat,rec=1)vertex(1,1),vertex(2,1)
    maxR=vertex(1,1)
    maxZ=vertex(2,1)
    minR=vertex(1,1)
    minZ=vertex(2,1)
    do j=2,nodesCount2D
        read(rz_dat,rec=j)vertex(1,j),vertex(2,j)
        if(vertex(1,j).gt.maxR)maxR=vertex(1,j)
        if(vertex(1,j).lt.minR)minR=vertex(1,j)
        if(vertex(2,j).gt.maxZ)maxZ=vertex(2,j)
        if(vertex(2,j).lt.minZ)minZ=vertex(2,j)
    enddo

    do j=1,elemsCount2D
        read(nvkat2D_dat,rec=j)nInCat2D(j)
        read(nvtr_dat,rec=j)nVer(3,j),nVer(4,j),nVer(1,j),nVer(2,j),nVer(5,j),nVer(6,j)
    enddo

    do j=1,nodesTermCount2D+1
        read(ig_dat,rec=j)igT(j)
    enddo
    mTerm2d=igT(nodesTermCount2D+1)-1

    do j=1,mTerm2d
        read(jg_dat,rec=j)jgT(j)
        read(gg_dat,rec=j)ggT(j)
    enddo

    do j=1,nodesBoundCount2D
        read(l1_dat,rec=j)l1(j)
    enddo

    do j=1,nPoints
        read(points_txt,*)points(1,j),points(2,j),points(3,j)
    enddo

    do j=1,elemsCount2D
        numbersEl(1,nVer(1,j)) = j
        numbersEl(2,nVer(2,j)) = j
        numbersEl(3,nVer(3,j)) = j
        numbersEl(4,nVer(4,j)) = j
    enddo
end
!*************************************************************************
!*************************************************************************
!*************************************************************************